package cn.exrick.front.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class InterceptorConfiguration extends WebMvcConfigurerAdapter {

    @Autowired
    private LimitRaterInterceptor limitRaterInterceptor;
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 注册拦截器
        InterceptorRegistration ir = registry.addInterceptor(limitRaterInterceptor);
        // 配置拦截的路径
        ir.addPathPatterns("/**");

        InterceptorRegistration loginIr = registry.addInterceptor(loginInterceptor);
        loginIr.addPathPatterns("/order/**");
        loginIr.addPathPatterns("/cart/**");
        loginIr.addPathPatterns("/advice/**");
        loginIr.addPathPatterns("/address/**");
        loginIr.addPathPatterns("/member/personalCenter");
        loginIr.addPathPatterns("/member/getPersonalInfo");
        loginIr.addPathPatterns("/member/modifyPassword");
        loginIr.addPathPatterns("/member/update");
        loginIr.excludePathPatterns("/order/notify");
        loginIr.excludePathPatterns("/order/return");
    }
}
